package com.clover.video.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

public class RegexUtils {
    public static  List<String[]> regMatchGroupList(String pattern, String str, int[] groupArr) throws PatternSyntaxException {
        List<String[]> list = new ArrayList<String[]>();
        try {
            Pattern p = Pattern.compile(pattern);
            Matcher m = p.matcher(str);
            while (m.find()) {
                String[] arr = new String[groupArr.length];
                int i = 0;
                for (Integer index : groupArr) {
                    arr[i] = m.group(index);
                    i++;
                }
                list.add(arr);
            }
        } catch (PatternSyntaxException e) {
            throw e;
        }
        return list;
    }

    public static boolean match(String pattern, String str) {
        String returnValue = null;
        try {
            Pattern p = Pattern.compile(pattern);
            Matcher m = p.matcher(str);
            while (m.find()) {
                return true;
            }
        } catch (PatternSyntaxException e) {
        }
        return false;
    }
}
